package com.xbongbong.paas.help;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.MessageConstant;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.PaasFormEntity;
import com.xbongbong.paas.domain.entity.PaasFormExplainEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkInfoPojo;
import com.xbongbong.paas.field.LinkedAttrPoJo;
import com.xbongbong.paas.model.PaasFormExplainModel;
import com.xbongbong.paas.model.PaasFormModel;
import com.xbongbong.paas.pojo.FormExplainPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.paas.util.ExplainUtil;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.form.pojo.RuleTargetPojo;
import com.xbongbong.pro.formexplain.pojo.dto.FilterExplainByRuleDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.entity.ext.WorkOrderExplainEntityExt;
import com.xbongbong.saas.domain.entity.ext.WorkOrderFormEntityExt;
import com.xbongbong.saas.enums.RedundantTemplateTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.help.DefaultAttrHelp;
import com.xbongbong.saas.model.AssembleModel;
import com.xbongbong.saas.model.BomBillModel;
import com.xbongbong.saas.model.ClueModel;
import com.xbongbong.saas.model.ContractModel;
import com.xbongbong.saas.model.CostAdjustModel;
import com.xbongbong.saas.model.CustomerCommunicateModel;
import com.xbongbong.saas.model.CustomerModel;
import com.xbongbong.saas.model.DistributorAccountModel;
import com.xbongbong.saas.model.InstockModel;
import com.xbongbong.saas.model.InventoryModel;
import com.xbongbong.saas.model.InvoiceModel;
import com.xbongbong.saas.model.OpportunityModel;
import com.xbongbong.saas.model.OtherExpenseModel;
import com.xbongbong.saas.model.OtherIncomeModel;
import com.xbongbong.saas.model.OutstockModel;
import com.xbongbong.saas.model.PayPlanModel;
import com.xbongbong.saas.model.PayPlanSheetModel;
import com.xbongbong.saas.model.PaymentModel;
import com.xbongbong.saas.model.PaymentSheetModel;
import com.xbongbong.saas.model.PaymentTaskModel;
import com.xbongbong.saas.model.ProductModel;
import com.xbongbong.saas.model.ProductionOrderModel;
import com.xbongbong.saas.model.PurchaseInvoiceModel;
import com.xbongbong.saas.model.PurchaseModel;
import com.xbongbong.saas.model.QuotationModel;
import com.xbongbong.saas.model.RefundModel;
import com.xbongbong.saas.model.ReturnedPurchaseModel;
import com.xbongbong.saas.model.SupplierCommunicateModel;
import com.xbongbong.saas.model.SupplierContactModel;
import com.xbongbong.saas.model.SupplierModel;
import com.xbongbong.saas.model.TransferModel;
import com.xbongbong.saas.model.WorkOrderExplainModel;
import com.xbongbong.saas.model.WorkOrderFormModel;
import com.xbongbong.saas.model.WorkOrderModel;
import com.xbongbong.saas.model.WorkReportModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Component
public class FormExplainHelp {

    private static final Logger LOG = LoggerFactory.getLogger(FormExplainHelp.class);

    @Resource
    private OpportunityModel opportunityModel;
    @Resource
    private BomBillModel bomBillModel;
    @Resource
    private CustomerCommunicateModel customerCommunicateModel;
    @Resource
    private SupplierCommunicateModel supplierCommunicateModel;
    @Resource
    private WorkReportModel workReportModel;
    @Resource
    private ContractModel contractModel;
    @Resource
    private InstockModel instockModel;
    @Resource
    private SupplierModel supplierModel;
    @Resource
    private ProductionOrderModel productionOrderModel;
    @Resource
    private InvoiceModel invoiceModel;
    @Resource
    private PurchaseInvoiceModel purchaseInvoiceModel;
    @Resource
    private InventoryModel inventoryModel;
    @Resource
    private PurchaseModel purchaseModel;
    @Resource
    private ReturnedPurchaseModel returnedPurchaseModel;
    @Resource
    private TransferModel transferModel;
    @Resource
    private AssembleModel assembleModel;
    @Resource
    private PaymentModel paymentModel;
    @Resource
    private PayPlanModel payPlanModel;
    @Resource
    private SupplierContactModel supplierContactModel;
    @Resource
    private PaymentSheetModel paymentSheetModel;
    @Resource
    private PayPlanSheetModel payPlanSheetModel;
    @Resource
    private RefundModel refundModel;
    @Resource
    private WorkOrderModel workOrderModel;
    @Resource
    private OutstockModel outstockModel;
    @Resource
    private QuotationModel quotationModel;
    @Resource
    private DistributorAccountModel distributorAccountModel;
    @Resource
    private ClueModel clueModel;
    @Resource
    private DefaultAttrHelp defaultAttrHelp;
    @Resource
    private CustomerModel customerModel;
    @Resource
    private ProductModel productModel;
    @Resource
    private PaymentTaskModel paymentTaskModel;
    @Resource
    private OtherIncomeModel otherIncomeModel;
    @Resource
    private OtherExpenseModel otherExpenseModel;
    @Resource
    private FormDataFormExplainHelper formDataFormExplainHelper;
    @Resource
    private ProFormHelp proFormHelp;
    @Resource
    private CostAdjustModel costAdjustModel;
    @Resource
    private WorkOrderFormModel workOrderFormModel;
    @Resource
    private WorkOrderExplainModel workOrderExplainModel;
    @Resource
    private PaasFormModel paasFormModel;
    @Resource
    private PaasFormExplainModel paasFormExplainModel;

    /**
     * 字段可见
     * @param fieldAttrEntity 字段
     * @param dataId 数据id
     * @param creatorId 创建人
     * @param loginUser 登录人
     * @param corpid 公司id
     * @param businessType 业务类型
     * @return 是否可见 true可见；flase不可见
     */
    public Boolean attrCanSee(FieldAttrEntity fieldAttrEntity, Long dataId, String creatorId, UserVO loginUser, String corpid, int businessType) {
        if (fieldAttrEntity == null) {
            return false;
        }
        // 是否启用字段
        if (!Objects.equals(fieldAttrEntity.getIsOpen(), 1) || !Objects.equals(fieldAttrEntity.getVisible(), 1)) {
            return false;
        }
        //协同团队
        Map<Long, List<String>> mainUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Map<Long, List<String>> coUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        if (Objects.isNull(dataId)){
            formDataFormExplainHelper.getUserIdMap(Collections.singletonList(dataId), corpid, businessType, false, mainUserMap, coUserMap);
        }
        // 当前数据的创建人、负责人、协同人、当前操作人
        HandlerExplainDTO handlerExplainDTO = new HandlerExplainDTO();
        handlerExplainDTO.setLoginUser(loginUser);
        handlerExplainDTO.setOwnerId(mainUserMap.get(dataId));
        handlerExplainDTO.setCoUserId(coUserMap.get(dataId));
        handlerExplainDTO.setCreatorId(creatorId);
        handlerExplainDTO.setUserId(loginUser.getUserId());
        try {
            // 判断是否可见
            return !ExplainUtil.invisibleOfScope(fieldAttrEntity, handlerExplainDTO);
        } catch (Exception e) {
            LOG.error("判断字段是否启用且(高级)可见出错 commonHelp.attrCanSee:" );
            e.printStackTrace();
        }
        return false;
    }


    /**
     * saas编辑时给解释字段赋初始值,格式化
     *
     * @param formatExplainDTO 表单解释格式化入参
     * @param data
     * @throws XbbException 抛出业务异常
     * @author long.rao
     * @date 2019-02-13 20:58
     */
    public void formatExplain(FormatExplainDTO formatExplainDTO, JSONObject data) throws XbbException {
        Integer businessType = XbbRefTypeEnum.transferBusinessType4Distributor(formatExplainDTO.getBusinessType(), formatExplainDTO.getDistributorMark());
        if (businessType == null || businessType == 0) {
            LOG.error("businessType为空");
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100002, SystemErrorCodeEnum.API_ERROR_100002.getMsg());
        }
        RedundantTemplateTypeEnum templateTypeEnum = RedundantTemplateTypeEnum.getByCode(businessType);
        switch (templateTypeEnum) {
            case COMMUNICATE:
                customerCommunicateModel.formatUpdateExplain(formatExplainDTO);
                break;
            case JXC_COMMUNICATE:
                supplierCommunicateModel.formatUpdateExplain(formatExplainDTO);
                break;
            case SALES_OPPORTUNITY:
                opportunityModel.formatUpdateExplain(formatExplainDTO);
                break;
            case CUSTOMER:
                customerModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PRODUCT:
                // 产品编辑时如果是多规格，则成本和单价字段不显示
                productModel.formatUpdateExplain(formatExplainDTO, data);
                break;
            case BOMBILL:
                // bom单关联产品字段解释
                bomBillModel.formatUpdateExplain(formatExplainDTO);
                break;
            case QUOTATION:
                // bom单关联产品字段解释
                quotationModel.formatUpdateExplain(formatExplainDTO);
                break;
            case WORKREPORT_DAILY:
            case WORKREPORT_WEEKLY:
            case WORKREPORT_MONTHLY:
            case WORKREPORT:
                workReportModel.formatUpdateExplain(formatExplainDTO);
                break;
            case CONTRACT:
            case ORDER:
                contractModel.formatUpdateExplain(formatExplainDTO);
                break;
            case SUPPLIER:
                supplierModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PRODUCTIONORDER:
                productionOrderModel.formatUpdateExplain(formatExplainDTO);
                break;
            case INVOICE:
                // 发票
                invoiceModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PURCHASE_INVOICE:
                // 发票
                purchaseInvoiceModel.formatUpdateExplain(formatExplainDTO);
                break;
            case INVENTORY:
                inventoryModel.formatUpdateExplain(formatExplainDTO);
                break;
            case TRANSFER:
                transferModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PURCHASE:
                purchaseModel.formatUpdateExplain(formatExplainDTO);
                break;
            case RETURNED_PURCHASE:
                returnedPurchaseModel.formatUpdateExplain(formatExplainDTO);
                break;
            case OUTSTOCK:
            case CONTRACT_OUTSTOCK:
            case OTHER_OUTSTOCK:
            case PRODUCTION_MATERIEL_OUTSTOCK:
            case RETURNED_PURCHASE_OUTSTOCK:
            case WORK_ORDER_OUTSTOCK:
            case ORDER_OUTSTOCK:
                outstockModel.formatUpdateExplain(formatExplainDTO);
                break;
            case INSTOCK:
            case OTHER_INSTOCK:
            case PRODUCTION_INSTOCK:
            case PURCHASE_INSTOCK:
            case REFUND_INSTOCK:
            case RETURNED_MATERIEL_INSTOCK:
                instockModel.formatUpdateExplain(formatExplainDTO);
                break;
            case ASSEMBLE:
                assembleModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PAYMENT:
                paymentModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PAY_PLAN:
                payPlanModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PAYMENT_SHEET:
                paymentSheetModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PAY_SHEET:
                payPlanSheetModel.formatUpdateExplain(formatExplainDTO);
                break;
            case WORKORDER:
                workOrderModel.formatUpdateExplain(formatExplainDTO, data);
                break;
            case REFUND:
            case RETURN:
                refundModel.formatUpdateExplain(formatExplainDTO);
                break;
            case SUPPLIER_CONTACT:
                supplierContactModel.formatUpdateExplain(formatExplainDTO);
                break;
            case CLUE:
                clueModel.formatUpdateExplain(formatExplainDTO);
                break;
            case PAYMENT_TASK:
                paymentTaskModel.formatUpdateExplain(formatExplainDTO);
                break;
            case DISTRIBUTOR_MANAGEMENT:
                customerModel.formatUpdateExplainForDistributor(formatExplainDTO);
                break;
            case DISTRIBUTOR_ACCOUNT:
                distributorAccountModel.formatUpdateExplain(formatExplainDTO);
                break;
            case DISTRIBUTOR_CONTACT:
                break;
            case DISTRIBUTOR_COMMUNICATE:
                customerCommunicateModel.formatUpdateExplainForDistributor(formatExplainDTO);
                break;
            case OTHER_INCOME:
                otherIncomeModel.formatUpdateExplain(formatExplainDTO);
                break;
            case OTHER_EXPENSE:
                otherExpenseModel.formatUpdateExplain(formatExplainDTO);
                break;
            case COST_ADJUST:
                costAdjustModel.formatUpdateExplain(formatExplainDTO);
                break;
            default:
                break;
        }
        // 详情展示的字段移除
        List<Integer> showTypeList = Arrays.asList(ShowTypeEnum.ALL.getCode(), ShowTypeEnum.EDIT.getCode(), ShowTypeEnum.EDIT_LIST.getCode(), ShowTypeEnum.EDIT_DETAIL.getCode());
        for (FieldAttrEntity item : formatExplainDTO.getExplainList()) {
            if (Objects.equals(item.getFieldType(), FieldTypeEnum.SELECT_PRODUCT.getType())) {
                List<? extends FieldAttrEntity> subFormFieldList = item.getSubForm().getItems();
                Iterator<? extends FieldAttrEntity> iterator = subFormFieldList.iterator();
                while (iterator.hasNext()) {
                    FieldAttrEntity fieldAttrEntity = iterator.next();
                    if (Objects.equals(fieldAttrEntity.getAttr(), ProductEnum.NAME.getAttr())) {
                        List<LinkedAttrPoJo> linkedAttrPoJos = fieldAttrEntity.getLinkInfo().getLinkedAttr();
                        formatExplainDTO.setProductField(item);
                        defaultAttrHelp.addProductLinkAttr(XbbRefTypeEnum.getByCode(businessType), linkedAttrPoJos, formatExplainDTO);
                    } else {
                        if (!showTypeList.contains(fieldAttrEntity.getShowType()) && Objects.equals(fieldAttrEntity.getIsRedundant(), 0)) {
                            iterator.remove();
                        }
                    }
                }
                item.getSubForm().setItems(subFormFieldList);
            }
        }
    }

    /**
     * 业务规则添加所选数据，作为赋值项
     * @param list
     * @param fieldType
     * @param formId
     * @param businessType
     * @param linkInfoPojo
     */
    public void addDataIdInBusinessRule(List<FieldAttrEntity> list, Integer fieldType, Long formId, Integer businessType, LinkInfoPojo linkInfoPojo) {
        Boolean isLinkData = Objects.equals(FieldTypeEnum.LINK_DATA.getType(), fieldType) || Objects.equals(FieldTypeEnum.LINK_DATA_MULTI.getType(), fieldType);
        Long targetFormId = null;
        Integer targetBusinessType = null;
        if (Objects.nonNull(linkInfoPojo)) {
            targetFormId = linkInfoPojo.getLinkFormId();
            targetBusinessType = linkInfoPojo.getLinkBusinessType();
        }
        boolean sameFormId = Objects.equals(formId, targetFormId) && Objects.equals(businessType, targetBusinessType);
        if (isLinkData && sameFormId) {
            FieldAttrEntity fieldAttrEntity = new FieldAttrEntity();
            fieldAttrEntity.setAttr(FieldTypeEnum.DATAID.getAlias());
            fieldAttrEntity.setAttrName(I18nMessageUtil.getMessage(I18nStringConstant.SELECTED_DATA));
            fieldAttrEntity.setFieldType(FieldTypeEnum.DATAID.getType());
            list.add(fieldAttrEntity);
        }
    }

    /**
     * 业务规则添加所选数据，作为赋值项
     * @param list
     * @param fieldType
     * @param formId
     * @param businessType
     * @param linkInfoPojo
     */
    /**
     * 添加数据id作为条件
     *  @param list
     * @param fieldType
     * @param isFormName 是否把 “所选数据” 改为 表单名ID
     */
    public void addDataIdAsCondition(List<FieldAttrEntity> list, Integer fieldType, FilterExplainByRuleDTO filterExplainByRuleDTO, boolean isFormName) throws XbbException {

        Integer saasMark = filterExplainByRuleDTO.getSaasMark();
        Integer businessType = filterExplainByRuleDTO.getBusinessType();
        Integer fieldBusinessType = filterExplainByRuleDTO.getLinkedType();
        Long formId = filterExplainByRuleDTO.getFormId();
        LinkInfoPojo linkInfoPojo = filterExplainByRuleDTO.getLinkInfo();
        RuleTargetPojo ruleTargetPojo = filterExplainByRuleDTO.getTarget();
        Boolean isLinkData = Objects.equals(FieldTypeEnum.LINK_DATA.getType(), fieldType);
        Long targetFormId = null;
        if (Objects.nonNull(linkInfoPojo)) {
            targetFormId = linkInfoPojo.getLinkFormId();
            fieldBusinessType = linkInfoPojo.getLinkBusinessType();
            saasMark = linkInfoPojo.getLinkSaasMark();
        } else if (Objects.nonNull(ruleTargetPojo) && Objects.isNull(fieldBusinessType)) {
            // 业务规则中，判断目标表单和触发表单是同一个表单时，增加 数据id是否等于数据id
            targetFormId = ruleTargetPojo.getFormId();
            fieldBusinessType = ruleTargetPojo.getLinkBusinessType();
            saasMark = ruleTargetPojo.getLinkSaasMark();
        }

        // 系统表单中，需要与关联表业务一致
        boolean sameBusiness = Objects.equals(SaasMarkEnum.SAAS.getCode(), saasMark) && Objects.equals(businessType, fieldBusinessType);
        // 关联数据的自定义表单，表单id需要一致
        boolean sameFormId = Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark) && isLinkData && Objects.equals(formId, targetFormId);
        if (sameBusiness || sameFormId) {
            FieldAttrEntity fieldAttrEntity = new FieldAttrEntity();
            fieldAttrEntity.setAttr(FieldTypeEnum.DATAID.getAlias());
            fieldAttrEntity.setAttrName(I18nMessageUtil.getMessage(I18nStringConstant.SELECTED_DATA));
            if (isFormName && Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
                PaasFormEntity paasFormEntity = proFormHelp.getPaasForm(targetFormId, fieldBusinessType, filterExplainByRuleDTO.getCorpid());
                fieldAttrEntity.setAttrName(paasFormEntity.getName() + "ID");
            } else if (isFormName && Objects.equals(SaasMarkEnum.SAAS.getCode(), saasMark)) {
                RedundantTemplateTypeEnum redundantTemplateTypeEnum = RedundantTemplateTypeEnum.getByCode(businessType);
                fieldAttrEntity.setAttrName(redundantTemplateTypeEnum.getName()+ "ID");
            }
            fieldAttrEntity.setFieldType(FieldTypeEnum.DATAID.getType());
            list.add(fieldAttrEntity);
        }
    }

    /**
     * 获取表单名称、表单解释、distributorMark等信息
     * @param corpid
     * @param businessType
     * @param formId
     * @return com.xbongbong.paas.pojo.FormExplainPojo
     * @throws XbbException
     * @author 鲁江、伟强、魏铭
     * @since v1.0
     * @version v1.0
     * @update 2022.7.5 by zcp 从 ChartServiceImpl#setDataSourceAttrVO方法内抽取，逻辑未做变动
     */
    public FormExplainPojo getFormAndExplain(String corpid, Integer businessType, Long formId) throws XbbException {
        PaasFormExplainEntity paasFormExplainEntity = new PaasFormExplainEntity();
        String formName;
        Integer distributorMark = DistributorMarkEnum.OTHER.getCode();
        if (Objects.equals(XbbRefTypeEnum.WORK_ORDER.getCode(), businessType)) {
            //工单
            // 查看表单主表信息
            WorkOrderFormEntityExt workOrderFormEntityExt = workOrderFormModel.getByKey(formId, corpid);
            if (workOrderFormEntityExt == null) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100404, MessageConstant.FORM_NOT_EXIST);
            }
            //解释表信息
            WorkOrderExplainEntityExt workOrderExplainEntityExt = workOrderExplainModel.getByFormId(formId, corpid);
            if (workOrderExplainEntityExt == null) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100404, MessageConstant.FORM_EXPLAIN_NOT_EXIST);
            }
            BeanUtil.copyProperties(workOrderExplainEntityExt, paasFormExplainEntity);
            formName = workOrderFormEntityExt.getName();
        } else {
            //WorkOrderV2NodeLogInfo非常规表单,走特殊逻辑
            if (Objects.equals(XbbRefTypeEnum.WORK_ORDER_V2_NODE_LOG_INFO.getCode(), businessType)){
                List<FieldAttrEntity> explainList = JSONArray.parseArray(StringConstant.WORK_ORDER_V2_NODE_LOG_INFO_EXPLAIN, FieldAttrEntity.class);
                explainList.forEach(entity -> entity.setFormId(formId));
                return new FormExplainPojo(I18nMessageUtil.getMessage(StringConstant.WORK_ORDER_V2_NODE_LOG_INFO_NAME), explainList, DistributorMarkEnum.OTHER.getCode(), null);
            }
            // 查看表单主表信息
            PaasFormEntityExt paasFormEntityExt = paasFormModel.getByKey(formId, corpid);
            if (paasFormEntityExt == null) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100404, MessageConstant.FORM_NOT_EXIST);
            }
            //解释表信息
            paasFormExplainEntity = paasFormExplainModel.getByFormId(formId, corpid);
            if (paasFormExplainEntity == null) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100404, MessageConstant.FORM_EXPLAIN_NOT_EXIST);
            }
            formName = paasFormEntityExt.getName();
            distributorMark = paasFormEntityExt.getDistributorMark();
        }
        Long appId = paasFormExplainEntity.getAppId();
        List<FieldAttrEntity> explainList = JSONArray.parseArray(paasFormExplainEntity.getExplains(), FieldAttrEntity.class);
        //todo 工单暂时过滤掉 阶段 阶段名称
        if (Objects.equals(XbbRefTypeEnum.WORK_ORDER.getCode(), businessType)) {
            explainList.removeIf(explain -> Objects.equals(explain.getFieldType(), FieldTypeEnum.WORK_ORDER_STAGE.getType()) || Objects.equals(explain.getFieldType(), FieldTypeEnum.WORK_ORDER_STAGE_NAME.getType()));
        }
        for (FieldAttrEntity fieldAttrEntity : explainList) {
            fieldAttrEntity.setFormId(formId);
        }
        return new FormExplainPojo(formName, explainList, distributorMark, appId);
    }
}
